﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    class CombinationExample05
    {
        static void Main ()
        {
            int n = 10;
            int k = 7;
            long rank = 110;

            // Make a new instance:

            Combination cn = new Combination (n, k, rank);

            // Elements may be accessed using the default iterator:

            foreach (int element in cn)
                Console.Write ((char) ('A' + element));

            Console.WriteLine ("\n");

            // Elements may be accessed using the index operator:

            for (int i = 0; i < cn.Picks; ++i)
                Console.WriteLine ("Element at {0} is {1}", i, cn[i]);
        }

        /* Output:

        BDFGHIJ

        Element at 0 is 1
        Element at 1 is 3
        Element at 2 is 5
        Element at 3 is 6
        Element at 4 is 7
        Element at 5 is 8
        Element at 6 is 9

        */
    }
}
